package com.qinge.blog.service.impl;

import com.qinge.blog.entity.*;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qinge.blog.dao.BlogRoleRouteDao;
import com.qinge.blog.service.BlogRoleRouteService;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author QDW
 * @date 2022-05-02 23:38:51
 * @description BlogRoleRoute service层实现类
 */
@Service
public class BlogRoleRouteServiceImpl  implements BlogRoleRouteService {

    @Resource
    BlogRoleRouteDao roleRouteDao;

    @Override
    public List<String> findRoleNamesByRoute(String route) {
        BlogRoleRouteExample example=new BlogRoleRouteExample();
        BlogRoleRouteExample.Criteria criteria=example.createCriteria();

        criteria.andRouteEqualTo(route);

        List<BlogRoleRoute> list=roleRouteDao.selectByExample(example);

        List<String> roles= list.stream().map(BlogRoleRoute::getRoleName).collect(Collectors.toList());

        return  roles;
    }
}

